home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / misc / edu / Calgor.lha / Cal / CalSource / sysanim.c < prev   
Encoding:
C/C++ Source or Header  |  1996-03-22  |  39.6 KB  |  1,487 lines

  1. /* Copyright © 1995-1996 : David Atkinson */
  2. /* V1.21 Sysanim.c */
  3. /* Calgor */
  4.  
  5. #include<stdio.h>
  6. #include<stdlib.h>
  7. #include<signal.h>
  8. #include<string.h>
  9. #include<hold/extra.h>
  10. #include<intuition/intuition.h>
  11. #include<exec/types.h>
  12. #include<graphics/gfxbase.h>
  13. #include<graphics/gfxmacros.h>
  14. #include<graphics/sprite.h>
  15. #include<clib/exec_protos.h>
  16. #include<clib/wb_protos.h>
  17. #include<clib/graphics_protos.h>
  18. #include<clib/dos_protos.h>
  19. #include<clib/exec_protos.h>
  20. #include<clib/intuition_protos.h>
  21.  
  22. #ifdef(V3)
  23. #endif
  24.  
  25. typedef struct RastPort * RASTPTR;
  26. typedef struct SimpleSprite * SSPTR;
  27.  
  28. extern void look_buf(char *[], int);
  29. extern void handler(int);
  30. extern void alert(char *);
  31. extern void copy_object(int,long,long,struct BitMap *);
  32. extern itochar(int, char []);
  33. extern void whatisit(char *);
  34. extern void al_clean(void);
  35. extern char check_index(char *);
  36. extern void get_road(PLAN);
  37. extern int putback(char *,int,VALUE);
  38. extern PLAN get_splan(int);
  39. extern void plan_clear(PLAN);
  40. extern SHORT anim_button(void);
  41. extern void back_drop(void);
  42. extern void shutdown(void);
  43. extern void clearkeybuf(void);
  44. extern void show_display(int);
  45.  
  46. extern struct Library *GfxBase;
  47. extern struct TextFont *cfontptr;
  48. extern char *display;
  49. extern char *text[LISTMAX];
  50. extern struct RastPort sec_rastport;
  51. extern struct ViewPort sec_viewport;
  52. extern struct View sec_view, *old_view;
  53. extern int stop;
  54. extern struct Window *my_window;
  55. extern struct Screen *my_screen;
  56. extern SHORT squeek[2];
  57. extern BOOL keypress;
  58. extern BOOL lmbpress;
  59. extern BOOL wactive;
  60. extern struct BitMap sec_bitmap;
  61. extern VARBUILD argument[ARGNUM];
  62. extern ordersum[ARGNUM];
  63. extern int realindex;
  64. extern int dem_num;
  65. extern MAPDEM pathone[9];
  66. extern MAPDEM pathtwo[4];
  67. extern MAPDEM paththree[7];
  68. extern MAPDEM pathfour[3];
  69. extern MAPDEM pathfive[3];
  70. extern MAPDEM backone[4];
  71. extern ARECT Bplay;
  72. extern ARECT Bpause;
  73. extern ARECT Bffor;
  74. extern char editor[MAXCHARPATH];
  75. extern char choices[NUMOFOPT][SLENGTH];
  76. extern int old_dem;
  77.  
  78. void draw_modes(UBYTE, RASTPTR, long, long, UBYTE);
  79. void scrollup(void);
  80. void scrolldown(void);
  81. void writetxt(int,int,RASTPTR,char *);
  82. void writeline(char *,int);
  83. void linehl_on(void);
  84. void linehl_off(void);
  85. void compare_line(void);
  86. void go_code(int);
  87. void wowboy(void);
  88. void play_col(int);
  89. void pause_col(int);
  90. void ff_col(int);
  91. void clr_dem(void);
  92. void clr_compare(void);
  93. void indicator_clr(void);
  94. void clr_code(void);
  95. void clean_local(void);
  96. void speed(void);
  97. void forward_move(MAPDEM [], MAPDEM, MAPDEM, SSPTR tech);
  98. void backward_move(MAPDEM [], MAPDEM, MAPDEM, SSPTR tech);
  99. void change_col(short);
  100. void reset_sprites(void);
  101. void set_sprite(void);
  102. void killsprite(void);
  103. void comp_wrt(int ,char *);
  104. void comp_scroll(void);
  105. PLAN get_dest(char *);
  106. int get_src(char *);
  107. void question(char *);
  108. int calc(int, char, int);
  109. void put_road(PLAN);
  110. void chk_view(struct View *,struct View *);
  111. void engrave_iray(int,int,int);
  112. void engrave_int(int);
  113. void chill(int);
  114.  
  115. struct GfxBase *ps=NULL;
  116.  
  117. UWORD apat = { 0xFFFF };
  118.  
  119. char *raylist[RECUREDEPTH];
  120. FUNC func_index[FUNCMAX];
  121. PLAN array_map[ARRAYMAX][MEMMAX];
  122. PLAN dis_map[LEVEL][MAXACROSS];
  123. PLAN ic_map[FUNCMAX][VARMAX];
  124.  
  125. WORD rect[10]=
  126. {
  127.   415,435,
  128.   627,435,
  129.   627,505,
  130.   415,505,
  131.   415,435
  132. };
  133.  
  134. __aligned __chip UWORD pulse_data[10]=
  135. {
  136.   0x0000,0x0000,
  137.   0xE000,0x0000,
  138.   0xE000,0x0000,
  139.   0xE000,0x0000,
  140.   0x0000,0x0000
  141. };
  142.  
  143. /* Image Data */
  144.  
  145. __aligned __chip UWORD cart_data[34] = {
  146.   0x0000,0x0000,
  147.   0x0000,0xFFFF,
  148.   0x7FFE,0xFFFF,
  149.   0x7FFE,0xFFFF,
  150.   0x7FFE,0xFFFF,
  151.   0x7FFE,0xFFFF,
  152.   0x7FFE,0xFFFF,
  153.   0x7FFE,0xFFFF,
  154.   0x7FFE,0xFFFF,
  155.   0x7FFE,0xFFFF,
  156.   0x0000,0xFFFF,
  157.   0x0000,0x381C,
  158.   0x381C,0x542A,
  159.   0x381C,0x6C36,
  160.   0x381C,0x542A,
  161.   0x0000,0x381C,
  162.   0x0000,0x0000
  163. };
  164.  
  165.  
  166. __aligned __chip struct SimpleSprite pulse_sprite=
  167. {
  168.   pulse_data,
  169.   3,
  170.   290, 24,
  171.   4
  172. };
  173.  
  174. __aligned __chip struct SimpleSprite cart_sprite=
  175. {
  176.   cart_data,
  177.   15,
  178.   22, 318,
  179.   6
  180. };
  181.  
  182.  
  183.  
  184. BOOL locktwo = FALSE;    /* Second lock off-on for test display */
  185. int icnum=0;             /* Current array index */
  186. int pushn=0;             /* Depth of name list stack */
  187. int fnum=-1;             /* Function number currently being accessed */
  188. int raynum=-1;           /* Array Currently Being Accesed */
  189. int ref=0;               /* Reference point for code display scrolling */
  190. /* int mid=0;               Reference point for array display V.121 */
  191. BOOL lock=FALSE;         /* Lock off-on 0-1*/
  192. int pause=0;             /* Pause off-on */
  193. SHORT play = 0;          /* Play off-on */
  194. int dtype = 0;           /* Current type of data structure being excessed */
  195. int types = 0;           /* Old type of data structure */
  196. int let_across = 0;      /* Number of spaces to begining */
  197. char back_name[MAXILEN];
  198. int back_x  = 0;
  199. SHORT trip=1;            /* Used in timing sprite scrolling*/
  200. SHORT fraction=1;        /* Used in timing sprite scrolling */
  201. struct MsgPort *aport=NULL;  /* Message Port for appmenu items */
  202.  
  203.  
  204. void chill(int secs){
  205. SHORT timer;
  206.  
  207.    for(timer=0;timer<secs;timer++){
  208.      if(stop==0){
  209.        wowboy();
  210.        Delay(10);
  211.      }
  212.    }
  213. }
  214.  
  215. /* Draw_modes - Sets the appropriate Pens and drawing modes */
  216. /* draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1); Standard */
  217.  
  218. void draw_modes(UBYTE mask,RASTPTR rport,long col1,long col2,UBYTE mod)
  219. {
  220.      SetWrMsk(rport,mask)
  221.      SetAPen(rport,col1);
  222.      SetBPen(rport,col2);
  223.      SetOPen(rport,col1);
  224.      SetAfPt(rport,&apat,0);
  225.      SetDrMd(rport,mod);
  226. }
  227.  
  228.  
  229. /* Showcode - Displays the first five lines */
  230.  
  231. void showcode(void)
  232. {
  233. int maxw=0;
  234. int y;
  235.  
  236.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  237.     SetFont(&sec_rastport,cfontptr);
  238.     for(y=5;y<MAXLINE;y++){
  239.       if(text[y-5]){
  240.         maxw=strlen(text[y-5]);
  241.         if(maxw>CODEWIDTH)
  242.           maxw = CODEWIDTH;
  243.         Move(&sec_rastport,292,(55+(SPACE*y)) );
  244.         Text(&sec_rastport,text[y-5],maxw);
  245.       }
  246.     }
  247. }
  248.  
  249. /* Writetxt - Writes the given text at the given x and y */
  250.  
  251. void writetxt(int rank, int file, RASTPTR lilt,char *letters)
  252. {
  253.     if(letters!=NULL){
  254.       SetFont(lilt,cfontptr);
  255.       Move(lilt,rank,file);
  256.       if(letters!=NULL)
  257.       Text(lilt,letters,strlen(letters));
  258.     }
  259. }
  260.  
  261. /*  Writeline -  Writes one line of text (code player) */
  262.  
  263. void writeline(char *passage,int linenum){
  264. int maxl=0;
  265.  
  266.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  267.     SetFont(&sec_rastport,cfontptr);
  268.     Move(&sec_rastport,292,(55+(SPACE*linenum)) );
  269.     if(passage){
  270.       maxl=strlen(passage);
  271.       if(maxl>CODEWIDTH)
  272.         maxl=CODEWIDTH;
  273.       Text(&sec_rastport,passage,maxl);
  274.     }
  275. }
  276.  
  277. /* Scrolls text up one line (cp), switching off highlight first
  278.    And replaces with a line at the bottom */
  279.  
  280. void scrollup(void){
  281.  
  282. char *tail;
  283.  
  284.     wowboy();
  285.     if(stop==0){
  286.       if ( (ref+7<LISTMAX) ){
  287.         linehl_off();
  288.         SetBPen(&sec_rastport,A_LLGREY);
  289.         ScrollRaster(&sec_rastport,0,UP,282,47,619,178);
  290.         ref++;
  291.         tail=text[6+ref];
  292.         writeline(tail,11);
  293.       }
  294.    }
  295. }
  296.  
  297. /* Scrolls text down in code player, first switching highlight off */
  298.  
  299. void scrolldown(void){
  300.  
  301. char *head;
  302.  
  303.     wowboy();
  304.     if(stop==0){
  305.       if ( (ref-1)>=0 ) {
  306.         linehl_off();
  307.         ref--;
  308.         SetBPen(&sec_rastport,A_LLGREY);
  309.         ScrollRaster(&sec_rastport,0,DOWN,282,47,619,178);
  310.       }
  311.       if( (ref-5)>=0 ){
  312.          head=text[ref-5];
  313.          writeline(head,0);
  314.       }
  315.    }
  316. }
  317.  
  318. /* Switches highlight on (code player) */
  319.  
  320. void linehl_on(void){
  321.  
  322.    if(lock!=TRUE){
  323.      draw_modes(0xFD,&sec_rastport,A_ORANGE,A_BLACK,COMPLEMENT);
  324.      RectFill(&sec_rastport,282,102,619,113);
  325.      SetWrMsk(&sec_rastport,0xFF);
  326.      lock=TRUE;
  327.    }
  328. }
  329.  
  330. /* Switches highlight off (code player) */
  331.  
  332. void linehl_off(void){
  333.  
  334.    if(lock!=FALSE){
  335.      draw_modes(0xFD,&sec_rastport,A_LLGREY,A_BLACK,COMPLEMENT);
  336.      RectFill(&sec_rastport,282,102,619,113);
  337.      SetWrMsk(&sec_rastport,0xFF);
  338.      lock=FALSE;
  339.    }
  340. }
  341.  
  342. /* Highlight on-off switch for the test gadget */
  343.  
  344. void compare_line(void){
  345.  
  346.      if(locktwo != TRUE){
  347.        draw_modes(0xFD,&sec_rastport,A_ORANGE,A_BLACK,COMPLEMENT);
  348.        locktwo = TRUE;
  349.      }
  350.      else{
  351.        draw_modes(0xFD,&sec_rastport,A_LLGREY,A_BLACK,COMPLEMENT);
  352.        locktwo = FALSE;
  353.      }
  354.      RectFill(&sec_rastport,62,160,275,171);
  355.      SetWrMsk(&sec_rastport,0xFF);
  356. }
  357.  
  358.  
  359. /* go_code is a major function, takes an integer which is the referance
  360.    line number and scrolls code display to that line.
  361.    Activating highlight when finished */
  362.  
  363. void go_code(int level){
  364.  
  365. int line_move;
  366. int ryth;
  367.  
  368.   line_move=ref-level;  /* Uses a reference level to calculate up-down */
  369.   if (line_move<0){
  370.     for(ryth=0;ryth>line_move;ryth--){
  371.       scrollup();
  372.       if(stop==0){
  373.          linehl_on();     /* Switches individual line segments on */
  374.          chill( (STILL/5) / fraction);
  375.          linehl_off();
  376.       }
  377.     }
  378.   }
  379.   if (line_move>0){
  380.     for(ryth=0;ryth<line_move;ryth++){
  381.        scrolldown();
  382.        if(stop==0){
  383.          linehl_on();
  384.          chill( (STILL/5) / fraction);
  385.          linehl_off();
  386.        }
  387.     }
  388.   }
  389.   linehl_on();
  390.   wowboy();
  391.   chill((STILL/2)/fraction);
  392. }
  393.  
  394. /* chk_view takes the present view and the view you want, if they
  395.    are different then assume that someone is looking at a different
  396.    screen therefore save sprites last position and get rid.  Then wait
  397.    and let user get on with other things without taking up CPU cycles,
  398.    hopefully.  When my window is activated restore sprites
  399.    and restore screen. */
  400.  
  401. void chk_view(struct View *present, struct View *actual){
  402. MAPDEM pixie, imp;
  403. struct AppMenuItem *appitem=NULL;
  404. struct AppMessage *appmsg=NULL;
  405.  
  406.    if (actual!=present){
  407.      if(actual==&sec_view){
  408.        pixie.way = imp.way = (WORD) NULL;
  409.        pixie.x = pulse_sprite.x;
  410.        pixie.y = pulse_sprite.y;
  411.        imp.x = cart_sprite.x;
  412.        imp.y = cart_sprite.y;
  413.        killsprite();
  414.      }
  415.      appitem=AddAppMenuItemA(0L,(ULONG) NULL,"Restore_Calgor",aport,(struct TagItem *) NULL);
  416.      if(appitem){
  417.        shutdown(); /* Close Screen and Window */
  418.        WaitPort(aport);
  419.        while( appmsg = (struct AppMessage *) GetMsg(aport) ){
  420.          /* Don't have to do anything with it except reply back */
  421.          ReplyMsg( (struct Message *) appmsg);
  422.        }
  423.        RemoveAppMenuItem(appitem);
  424.        back_drop(); /* Open Screen and Window */
  425.      }
  426.      else{
  427.        clean_local();
  428.        alert("Failed To Add AppMenu (chk_view) \n");
  429.      }
  430.      if(actual==&sec_view){
  431.        set_sprite();
  432.        MoveSprite(&sec_viewport,&pulse_sprite,pixie.x,pixie.y);
  433.        MoveSprite(&sec_viewport,&cart_sprite,imp.x,imp.y);
  434.      }
  435.      LoadView(actual);
  436.    }
  437. }
  438.  
  439.  
  440. void wowboy(void){
  441. SHORT received = 0;
  442. ULONG lok;
  443. char filepath[MAXCHARPATH];
  444.  
  445.    if(stop==0){
  446.      do {
  447.         lok = LockIBase(0);
  448.         ps = (struct GfxBase *) GfxBase;
  449.         UnlockIBase(lok);
  450.         chk_view(ps->ActiView,&sec_view);
  451.         raise(SIGINT);
  452.         if( (lmbpress==TRUE) || (keypress==TRUE) ){
  453.           received = anim_button();
  454.           clearkeybuf();
  455.           switch(received){
  456.             case PLAYBUT : case NUM1KEY :
  457.               /* PLAY */
  458.               stop=pause=0;
  459.               pause_col(0);
  460.               trip=fraction=1;
  461.               play_col(1);
  462.               ff_col(0);
  463.               break;
  464.             case FFORBUT : case NUM2KEY :
  465.               /* FAST FORWARD */
  466.               if( (pause!=1) && (play == 1) ){
  467.                 ff_col(1);
  468.                 fraction +=4;
  469.                 if(fraction>1000)
  470.                   fraction=1000;
  471.                 trip = 1;
  472.               }
  473.               break;
  474.             case PAUSEBUT : case NUM3KEY :
  475.               /* PAUSE */
  476.               pause=1;
  477.               pause_col(1);
  478.               play_col(0);
  479.               ff_col(0);
  480.               break;
  481.             case STOPBUT : case NUM4KEY :
  482.               /* STOP */
  483.               dem_num=100;
  484.               pause=0;
  485.               pause_col(0);
  486.               play_col(0);
  487.               ff_col(0);
  488.               stop=1;
  489.               fraction=1000;
  490.               trip = 1200;
  491.               break;
  492.             case NOBUT :
  493.               break;
  494.             case EJECTBUT : case ESCKEY :
  495.               pause=0;
  496.               pause_col(0);
  497.               play_col(0);
  498.               ff_col(0);
  499.               stop=1;
  500.               fraction=1000;
  501.               trip = 1200;
  502.               break;
  503.             case INFOBUT : case NUM5KEY :
  504.              /* INFORMATION BUTTON */
  505.              if(pause==1){
  506.                killsprite();
  507.                shutdown();
  508.                LoadView(old_view);
  509.                strcpy(filepath,editor);
  510.                strcat(filepath," ");
  511.                strcat(filepath,ONETHREE);
  512.                strcat(filepath,&choices[8+(old_dem*2)][0]);
  513.                strcat(filepath,".txt");
  514.                system(filepath);
  515.                back_drop();
  516.                LoadView(&sec_view);
  517.                set_sprite();
  518.                reset_sprites();
  519.              }
  520.               break;
  521.             default :
  522.               clean_local();
  523.               alert("Undefined button press (wowboy)\n");
  524.               break;
  525.           }
  526.         }
  527.      } while (pause==1);
  528.    }
  529. }
  530.  
  531. /* Clear the code display, initilise variables and Control Structures */
  532. /* Calls the clr compare display */
  533.  
  534. void clr_code(void)
  535. {
  536. int d,z;
  537. int xposition = XPOS;
  538. int rayy = 40;
  539.  
  540.    back_x=let_across=pushn=stop=dtype=types=let_across=icnum=pause=ref=0;
  541.    play=0;
  542.    lock=locktwo=FALSE;
  543.    fraction=trip=1;
  544.    raynum=fnum=-1;
  545.    for(d=0;d<FUNCMAX;d++){
  546.      func_index[d].f_label = NULL;
  547.      func_index[d].occured[0] = '\0';
  548.      func_index[d].occured[1] = '\0';
  549.      for(z=0;z<VARMAX;z++){
  550.        ic_map[d][z].points.x = (WORD) ICSTARTX;
  551.        ic_map[d][z].points.y = (WORD) ICSTARTY;
  552.        ic_map[d][z].points.way = (WORD) FIN_D;
  553.        ic_map[d][z].p_name=NULL;
  554.        ic_map[d][z].eol.x = (WORD) ICSTARTX;
  555.        ic_map[d][z].eol.y = (WORD) (ICSTARTY + ADJUSTY);
  556.        ic_map[d][z].eol.way = (WORD) TERMINAL;
  557.      }
  558.    }
  559.    for(d=0;d<ARRAYMAX;d++){
  560.      for(z=0;z<MEMMAX;z++){
  561.        array_map[d][z].p_name = NULL;
  562.        array_map[d][z].points.x = (WORD) 0;
  563.        array_map[d][z].points.y = (WORD) 0;
  564.        array_map[d][z].points.way = (WORD) TERMINAL;
  565.        array_map[d][z].eol.x = (WORD) 0;
  566.        array_map[d][z].eol.y = (WORD) 0;
  567.        array_map[d][z].eol.way = (WORD) TERMINAL;
  568.      }
  569.    }
  570.    for(d=0;d<RECUREDEPTH;d++)
  571.      raylist[d]=NULL;
  572.    for(d=0;d<LEVEL;d++){
  573.      for(z=0;z<MAXACROSS;z++){
  574.        dis_map[d][z].p_name = NULL;
  575.        dis_map[d][z].points.x = (WORD) CARTX;
  576.        dis_map[d][z].points.y = (WORD) CARTY+rayy;
  577.        dis_map[d][z].points.way = (WORD) FIN_R;
  578.        dis_map[d][z].eol.x = (WORD) xposition;
  579.        dis_map[d][z].eol.y = (WORD) CARTY+rayy;
  580.        dis_map[d][z].eol.way = (WORD) TERMINAL;
  581.        xposition+=54L;
  582.      }
  583.      xposition = XPOS;
  584.      rayy+=32;
  585.    }
  586.    draw_modes(0xFF,&sec_rastport,A_LLGREY,A_LLGREY,JAM1);
  587.    RectFill(&sec_rastport,282,37,619,182);
  588.    clr_compare();
  589. }
  590.  
  591. void clr_dem(void)
  592. {
  593.   draw_modes(0xFF,&sec_rastport,A_LBLUE,A_LBLUE,JAM1);
  594.   RectFill(&sec_rastport,0,242,639,511);
  595.   RectFill(&sec_rastport,339,204,549,215);
  596. }
  597.  
  598. void clr_compare(void)
  599. {
  600.   draw_modes(0xFF,&sec_rastport,A_LLGREY,A_LLGREY,JAM1);
  601.   RectFill(&sec_rastport,62,92,275,182);
  602.   indicator_clr();
  603. }
  604.  
  605. void indicator_clr(void){
  606.  
  607.     copy_object(IOFF,32,98,&sec_bitmap);
  608.     copy_object(IOFF,32,147,&sec_bitmap);
  609. }
  610.  
  611. void play_col(int on_off)
  612. {
  613.    if (on_off==0){
  614.      draw_modes(0xFF,&sec_rastport,A_LGREY,A_LGREY,JAM1);
  615.      play = 0;
  616.    }
  617.    else{
  618.      draw_modes(0xFF,&sec_rastport,A_LGREEN,A_LGREEN,JAM1);
  619.      play = 1;
  620.    }
  621.    RectFill(&sec_rastport,Bplay.min.xc,Bplay.min.yc,Bplay.max.xc,Bplay.max.yc);
  622. }
  623.  
  624. void pause_col(int light)
  625. {
  626.    if (light==0){
  627.      draw_modes(0xFF,&sec_rastport,A_LGREY,A_LGREY,JAM1);
  628.    }
  629.    else{
  630.      draw_modes(0xFF,&sec_rastport,A_LGREEN,A_LGREEN,JAM1);
  631.    }
  632.    RectFill(&sec_rastport,Bpause.min.xc,Bpause.min.yc,Bpause.max.xc,Bpause.max.yc);
  633. }
  634.  
  635. void ff_col(int led)
  636. {
  637.    if (led==0){
  638.      draw_modes(0xFF,&sec_rastport,A_LGREY,A_LGREY,JAM1);
  639.    }
  640.    else{
  641.      draw_modes(0xFF,&sec_rastport,A_LGREEN,A_LGREEN,JAM1);
  642.    }
  643.    RectFill(&sec_rastport,Bffor.min.xc,Bffor.min.yc,Bffor.max.xc,Bffor.max.yc);
  644. }
  645.  
  646.  
  647. void set_sprite(void){
  648.   if( GetSprite(&pulse_sprite, 4) != 4 ){
  649.      clean_local();
  650.      alert("Failed sprite1 (set_sprite)\n");
  651.   }
  652.   if( GetSprite(&cart_sprite, 6) != 6){
  653.       clean_local();
  654.       alert("Failed sprite2 (set_sprite)\n");
  655.   }
  656. }
  657.  
  658. void reset_sprites(void){
  659.   change_col(0);
  660.   MoveSprite(&sec_viewport,&pulse_sprite,602,190);
  661.   MoveSprite(&sec_viewport,&cart_sprite,CARTX,CARTY);
  662. }
  663.  
  664. void change_col(short action){
  665.  
  666.   switch(action){
  667.     case 0 :
  668.       SetRGB4(&sec_viewport, 24,0,0,0);
  669.       SetRGB4(&sec_viewport, 25,2,0,15);
  670.       SetRGB4(&sec_viewport, 26,2,0,15);
  671.       SetRGB4(&sec_viewport, 27,2,0,15);
  672.       SetRGB4(&sec_viewport, 28,0,0,0);
  673.       SetRGB4(&sec_viewport, 29,7,7,7);
  674.       SetRGB4(&sec_viewport, 30,0,0,0);
  675.       SetRGB4(&sec_viewport, 31,9,3,2);
  676.       break;
  677.     case 1 :
  678.       SetRGB4(&sec_viewport, 24,0,0,0);
  679.       SetRGB4(&sec_viewport, 25,0,15,2);
  680.       SetRGB4(&sec_viewport, 26,0,15,2);
  681.       SetRGB4(&sec_viewport, 27,0,15,2);
  682.       SetRGB4(&sec_viewport, 28,0,0,0);
  683.       SetRGB4(&sec_viewport, 29,0,15,0);
  684.       SetRGB4(&sec_viewport, 30,0,0,0);
  685.       SetRGB4(&sec_viewport, 31,0,9,2);
  686.       break;
  687.    }
  688. }
  689.  
  690. void killsprite(void){
  691.  
  692.   if(pulse_sprite.num != -1){
  693.     FreeSprite( (WORD) pulse_sprite.num);
  694.     pulse_sprite.num=-1;
  695.   }
  696.   if(cart_sprite.num != -1){
  697.     FreeSprite( (WORD) cart_sprite.num);
  698.     cart_sprite.num=-1;
  699.   }
  700. }
  701.  
  702. void clean_local(void){
  703.   killsprite();
  704.   al_clean();
  705. }
  706.  
  707. void speed(void){
  708.   if (trip==fraction){
  709.      WaitBOVP(&sec_viewport);
  710.      trip=1;
  711.   }
  712.   else {
  713.     trip++;
  714.   }
  715. }
  716.  
  717. /* Forward_move and backward_move algorithms take a path, start, endpoints
  718.    and a pointer to a sprite. (Following revisions will have this as a pointer
  719.    to function in which animations can be utilised). The algorithms move the
  720.    sprite along the given path.  The path can contain many different points in which
  721.    the sprite can turn off.  However the sprite won't turn unless the finish given
  722.    matches the finish in the given path.  We can therefore reuse a path to specify
  723.    different animations */
  724.  
  725. void forward_move(MAPDEM travel[], MAPDEM start,MAPDEM finish, SSPTR tech){
  726. int count;
  727. BOOL end;
  728. WORD xmove, ymove;
  729.  
  730.    end=FALSE;
  731.    count=0;
  732.    MoveSprite(&sec_viewport,tech,start.x,start.y);
  733.    while(end!=TRUE){
  734.      wowboy();
  735.      xmove=travel[count].x;
  736.      ymove=travel[count].y;
  737.      switch(travel[count].way){
  738.         case ALEFT : case START_L :
  739.            while (xmove != travel[count+1].x){
  740.              MoveSprite(&sec_viewport,tech,xmove,ymove);
  741.              speed();  /* Do we change the speed? */
  742.              xmove--;  /* Move sprite by one */
  743.              wowboy(); /* Check if menu options have been pressed */
  744.            }
  745.            break;
  746.         case ARIGHT :  case START_R :
  747.            while (xmove != travel[count+1].x){
  748.              MoveSprite(&sec_viewport,tech,xmove,ymove);
  749.              speed();
  750.              xmove++;
  751.              wowboy();
  752.            }
  753.            break;
  754.         case AUP : case START_U :
  755.            while (ymove != travel[count+1].y){
  756.              MoveSprite(&sec_viewport,tech,xmove,ymove);
  757.              speed();
  758.              ymove--;
  759.              wowboy();
  760.            }
  761.            break;
  762.         case ADOWN :  case START_D :
  763.            while (ymove != travel[count+1].y){
  764.              MoveSprite(&sec_viewport,tech,xmove,ymove);
  765.              speed();
  766.              ymove++;
  767.              wowboy();
  768.            }
  769.            break;
  770.         case FIN_U :
  771.           if ((travel[count+1].x == finish.x) && (travel[count+1].y == finish.y)){
  772.             while (ymove != finish.y){
  773.               MoveSprite(&sec_viewport,tech,xmove,ymove);
  774.               speed();
  775.               ymove--;
  776.               wowboy();
  777.             }
  778.             end=TRUE;
  779.           }
  780.           break;
  781.         case FIN_D :
  782.           if ((travel[count+1].x == finish.x) && (travel[count+1].y == finish.y)){
  783.             while (ymove != finish.y){
  784.               MoveSprite(&sec_viewport,tech,xmove,ymove);
  785.               speed();
  786.               ymove++;
  787.               wowboy();
  788.             }
  789.             end=TRUE;
  790.           }
  791.           break;
  792.         case FIN_L :
  793.           if ((travel[count+1].x == finish.x) && (travel[count+1].y == finish.y)){
  794.              while (xmove != finish.x){
  795.                MoveSprite(&sec_viewport,tech,xmove,ymove);
  796.                speed();
  797.                xmove--;
  798.                wowboy();
  799.              }
  800.              end=TRUE;
  801.           }
  802.           break;
  803.         case FIN_R :
  804.           if ((travel[count+1].x == finish.x) && (travel[count+1].y == finish.y)){
  805.             while (xmove != finish.x){
  806.               MoveSprite(&sec_viewport,tech,xmove,ymove);
  807.               speed();
  808.               xmove++;
  809.               wowboy();
  810.             }
  811.             end=TRUE;
  812.           }
  813.           break;
  814.         case TERMINAL :
  815.           wowboy();
  816.           break;
  817.         default :
  818.           clean_local();
  819.           alert("Failed direction (forward_move)\n");
  820.           break;
  821.      }
  822.      count++;
  823.    }
  824. }
  825.  
  826. void backward_move(MAPDEM get_road[], MAPDEM s_start,MAPDEM sprfin, SSPTR tech)
  827. {
  828. int increase;
  829. BOOL fin;
  830. WORD spritx, sprity;
  831.  
  832.    fin=FALSE;
  833.    increase=0;
  834.    spritx = get_road[increase].x;
  835.    sprity = get_road[increase].y;
  836.    while( (spritx!=s_start.x)  || (sprity!=s_start.y) ){
  837.      increase++;
  838.      sprity = get_road[increase].y;
  839.      spritx = get_road[increase].x;
  840.    }
  841.    MoveSprite(&sec_viewport,tech,s_start.x,s_start.y);
  842.    while(increase > 0){
  843.      wowboy();
  844.      switch(get_road[increase-1].way){
  845.         case ALEFT : case FIN_L : case START_L :
  846.            while (spritx != get_road[increase-1].x){
  847.              MoveSprite(&sec_viewport,tech,spritx,sprity);
  848.              speed();
  849.              spritx++;
  850.              wowboy();
  851.            }
  852.            break;
  853.         case ARIGHT :  case FIN_R : case START_R :
  854.            while (spritx != get_road[increase-1].x){
  855.              MoveSprite(&sec_viewport,tech,spritx,sprity);
  856.              speed();
  857.              spritx--;
  858.              wowboy();
  859.            }
  860.            break;
  861.         case AUP : case FIN_U :  case START_U :
  862.            while (sprity != get_road[increase-1].y){
  863.              MoveSprite(&sec_viewport,tech,spritx,sprity);
  864.              speed();
  865.              sprity++;
  866.              wowboy();
  867.            }
  868.            break;
  869.         case ADOWN : case FIN_D : case START_D :
  870.            while (sprity != get_road[increase-1].y){
  871.              MoveSprite(&sec_viewport,tech,spritx,sprity);
  872.              speed();
  873.              sprity--;
  874.              wowboy();
  875.            }
  876.            break;
  877.         case TERMINAL :
  878.           wowboy();
  879.           break;
  880.         default :
  881.           clean_local();
  882.           alert("Failed direction (backward_move)\n");
  883.           break;
  884.      }
  885.      increase--;
  886.    }
  887. }
  888.  
  889. /* Comp_wrt writes text to the compare display.  torite is
  890.    the number of spaces across the text should be printed. */
  891.  
  892. void comp_wrt(int torite,char *words){
  893. int cmpmax=0;
  894.  
  895.     /* Make sure we haven't got a NULL string */
  896.     if(words){
  897.       cmpmax=strlen(words);
  898.       if( (torite+cmpmax) <= COMPWIDTH) {  /* Check width is within Max  Range */
  899.         if (locktwo==TRUE) /* Switch highlight off if on */
  900.           compare_line();
  901.         draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  902.         writetxt((64+(torite*LETWIDTH)),168,&sec_rastport,words);
  903.         compare_line();
  904.       }
  905.     }
  906. }
  907.  
  908. /* comp_scroll, scrolls by one line the information in the compare display */
  909.  
  910. void comp_scroll(void){
  911.     wowboy();
  912.     if(stop==0){
  913.       if (locktwo==TRUE) compare_line();
  914.       SetBPen(&sec_rastport,A_LLGREY);
  915.       ScrollRaster(&sec_rastport,0,UP,62,(182-8*UP),275,182);
  916.     }
  917. }
  918.  
  919. PLAN get_dest(char *destname){
  920. PLAN dest;
  921.  
  922.       let_across=0;
  923.       plan_clear(dest);
  924.       whatisit(destname);
  925.       dest = get_splan(0);
  926.       whatisit(destname);
  927.       back_x = realindex;
  928.       dtype = types;
  929.       if(dest.p_name==NULL){
  930.          clean_local();
  931.          alert("Failed to locate dest coords (a_intass)\n");
  932.       }
  933.       if(strlen(dest.p_name)>=MAXILEN ){
  934.         clean_local();
  935.         alert("The length of the variable name exceeds limits (a_intass)\n");
  936.       }
  937.       strcpy(back_name,dest.p_name);
  938.       get_road(dest);
  939.       comp_wrt(let_across,destname);
  940.       if(destname!=NULL)
  941.         let_across += strlen(destname)+1;
  942.       else
  943.         let_across++;
  944.       comp_wrt(let_across,"=");
  945.       let_across+=2;
  946.       al_clean();
  947.       backward_move(pathone,pathone[8],pathone[0],&pulse_sprite);
  948.       return dest;
  949. }
  950.  
  951. int get_src(char *comname){
  952.  
  953. PLAN source;
  954. int total=0;
  955. int deal=0;
  956. int ct =0;
  957. int lt;
  958. char numname[LETWIDTH];
  959. char sad[2]={'\0','\0'};
  960.  
  961.       plan_clear(source);
  962.       whatisit(comname);
  963.       source=get_splan(deal);
  964.       whatisit(comname);
  965.       total=source.worth.number;
  966.       if(source.p_name==NULL){
  967.          clean_local();
  968.          alert("Failed to locate source coords (get_src)\n");
  969.       }
  970.       get_road(source);
  971.       itochar(source.worth.number,numname);
  972.       comp_wrt(let_across,numname);
  973.       if(numname!=NULL)
  974.         let_across += strlen(numname)+1;
  975.       else
  976.         let_across++;
  977.       deal++;
  978.       while( (argument[deal-1].sign[0]!='\0') && (deal<ARGNUM) ){
  979.          source=get_splan(deal);
  980.          whatisit(comname);
  981.          lt=calc(total,argument[deal-1].sign[0],source.worth.number);
  982.          total=lt;
  983.          if(source.p_name==NULL){
  984.             clean_local();
  985.             alert("Failed to locate source coords (get_src)\n");
  986.          }
  987.          get_road(source);
  988.          switch(argument[deal-1].sign[0]){
  989.            case '/' :
  990.              sad[0]='/';
  991.              break;
  992.            case '*'  :
  993.              sad[0]='*';
  994.              break;
  995.            case '+' :
  996.              sad[0]='+';
  997.              break;
  998.            case '-' :
  999.              sad[0]='-';
  1000.              break;
  1001.            default :
  1002.              clean_local();
  1003.              alert("Failed to identify sign (get_src)\n");
  1004.            break;
  1005.          }
  1006.          comp_wrt(let_across,sad);
  1007.          let_across+=2;
  1008.          itochar(source.worth.number,numname);
  1009.          comp_wrt(let_across,numname);
  1010.          if(numname!=NULL)
  1011.            let_across += strlen(numname)+1;
  1012.          else
  1013.            let_across++;
  1014.          deal++;
  1015.       }
  1016.       al_clean();
  1017.       return total;
  1018. }
  1019.  
  1020.  
  1021. int calc(int left,char how,int right){
  1022. int part;
  1023.  
  1024.   switch(how){
  1025.     case '/' :
  1026.       part = left / right;
  1027.       break;
  1028.     case '*' :
  1029.       part = left * right;
  1030.       break;
  1031.     case '+' :
  1032.       part = left + right;
  1033.       break;
  1034.     case '-' :
  1035.       part = left - right;
  1036.       break;
  1037.     default :
  1038.       clean_local();
  1039.       alert("Undefined symbol In (calc)\n");
  1040.       break;
  1041.     }
  1042.     return part;
  1043. }
  1044.  
  1045. void put_road(PLAN route){
  1046. WORD pix_x,pix_y;
  1047. char obval[LETWIDTH];
  1048.  
  1049.    change_col( (short) PUT);
  1050.    switch(dtype){
  1051.      case ICVAR :
  1052.        pix_x=route.points.x-ADJUSTX;
  1053.        pix_y=route.points.y;
  1054.        itochar(route.worth.number,obval);
  1055.        backone[1].way=ARIGHT;
  1056.        backone[2]=route.points;
  1057.        backone[3]=route.eol;
  1058.        forward_move(backone,backone[0],backone[3],&pulse_sprite);
  1059.        draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1060.        copy_object(VAR,pix_x+2,pix_y,&sec_bitmap);
  1061.        writetxt(pix_x+4,pix_y+39,&sec_rastport,back_name);
  1062.        writetxt(pix_x+4,pix_y+54,&sec_rastport,obval);
  1063.        chill((STILL/2)/fraction);
  1064.        backward_move(backone,backone[3],backone[0],&pulse_sprite);
  1065.        backward_move(pathone,pathone[8],pathone[0],&pulse_sprite);
  1066.        break;
  1067.      case ICRAY :
  1068.        pix_x=route.eol.x;
  1069.        pix_y=YPOS;
  1070.        backone[1].way = FIN_L;
  1071.        backone[2].x=38;
  1072.        backone[2].y=236;
  1073.        backone[2].way=TERMINAL;
  1074.        pathfour[1]=route.points;
  1075.        pathfour[2]=route.eol;
  1076.        forward_move(backone,backone[0],backone[2],&pulse_sprite);
  1077.        forward_move(pathfour,pathfour[0],pathfour[2],&cart_sprite);
  1078.        draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1079.        copy_object(IAR,pix_x,pix_y,&sec_bitmap);
  1080.        itochar(back_x,obval);
  1081.        writetxt(pix_x+2,pix_y+19,&sec_rastport,obval);
  1082.        itochar(route.worth.number,obval);
  1083.        writetxt(pix_x+2,pix_y+9,&sec_rastport,back_name);
  1084.        writetxt(pix_x+27,pix_y+9,&sec_rastport,obval);
  1085.        chill((STILL/2)/fraction);
  1086.        backward_move(pathfour,pathfour[2],pathfour[0],&cart_sprite);
  1087.        backward_move(backone,backone[2],backone[0],&pulse_sprite);
  1088.        backward_move(pathone,pathone[8],pathone[0],&pulse_sprite);
  1089.        break;
  1090.      default :
  1091.        clean_local();
  1092.        alert("ERROR In (put_road)\n");
  1093.        break;
  1094.   }
  1095. }
  1096.  
  1097. void a_func(char *fname, int f_hlp){
  1098.  
  1099.   if (stop==0){
  1100.     icnum=0;
  1101.     fnum++;
  1102.     if (fnum>=FUNCMAX){
  1103.       clean_local();
  1104.       alert("Maximum functions exceeded (a_func)\n");
  1105.     }
  1106.     /* How many times does function exist? */
  1107.     func_index[fnum].occured[0]=check_index(fname);
  1108.     func_index[fnum].f_label = fname;
  1109.     func_index[fnum].occured[1]='\0';
  1110.     clr_dem();
  1111.     copy_object(HOLE,8L, 242L, &sec_bitmap);
  1112.     go_code(f_hlp);
  1113.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1114.     Move(&sec_rastport,rect[0],rect[1]);
  1115.     /* PolyDraw(&sec_rastport,(WORD) 5,rect); */
  1116.     writetxt(341,212,&sec_rastport,func_index[fnum].f_label);
  1117.     writetxt(540,212,&sec_rastport,func_index[fnum].occured);
  1118.   }
  1119. }
  1120.  
  1121. /* a_rayini Initilises position and value data for an integer array */
  1122.  
  1123. void a_irayini(int first[],char *rayname,int members, int iray_hlp){
  1124. int r;
  1125.  
  1126.   go_code(iray_hlp);
  1127.   if(stop==0){
  1128.     raynum++; /* Next Array Please */
  1129.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1130.     if( (members>MEMMAX) || (raynum>=ARRAYMAX) ){
  1131.       clean_local();
  1132.       alert("Exceeded Max Members-200 Or Exceeded Ray Depth 1 (a_rayini)\n");
  1133.     }
  1134.     for(r=0;r<members;r++){
  1135.       array_map[raynum][r].points.x = (WORD) 0;
  1136.       array_map[raynum][r].points.y = (WORD) 0;
  1137.       array_map[raynum][r].points.way = (WORD) FIN_R;
  1138.       array_map[raynum][r].p_name = rayname;
  1139.       array_map[raynum][r].eol.x = (WORD) 0;
  1140.       array_map[raynum][r].eol.y = (WORD) 0;
  1141.       array_map[raynum][r].eol.way = (WORD) TERMINAL;
  1142.       array_map[raynum][r].worth.number = first[r];
  1143.     }
  1144.     r=0;
  1145.     while( (r<MAXACROSS) && (r<members) ){
  1146.       engrave_iray(r,r,0);
  1147.       r++;
  1148.     }
  1149.     chill((STILL/2)/fraction);
  1150.   }
  1151. }
  1152.  
  1153.  /* engrave_iray: Prints all aspects of an array graphic. Set
  1154.     draw_modes before calling this function  */
  1155.  
  1156. void engrave_iray(int start, int raydex, int depth){
  1157. char memnum[LETWIDTH];
  1158. int across;
  1159.  
  1160.     dis_map[depth][start].p_name = array_map[raynum][raydex].p_name;
  1161.     dis_map[depth][start].worth.number = array_map[raynum][raydex].worth.number;
  1162.     across = dis_map[depth][start].eol.x;
  1163.     copy_object(IAR,across,YPOS,&sec_bitmap); /* Print array graphic */
  1164.     itochar(raydex,memnum); /* Convert index */
  1165.     writetxt(across+2,YPOS+19,&sec_rastport,memnum);
  1166.       /* Print arrays index */
  1167.     itochar(dis_map[depth][start].worth.number,memnum);
  1168.     writetxt(across+2,YPOS+9,&sec_rastport,dis_map[depth][start].p_name);
  1169.       /* Print arrays name */
  1170.     writetxt(across+27,YPOS+9,&sec_rastport,memnum);
  1171.       /* Print arrays value */
  1172. }
  1173.  
  1174.  
  1175. void a_intini(int ivalue,char *iname, int i_hlp){
  1176. WORD across, down;
  1177.  
  1178.   go_code(i_hlp);
  1179.   if(stop==0){
  1180.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1181.     across=ic_map[fnum][icnum].points.x-ADJUSTX;
  1182.     down=ic_map[fnum][icnum].points.y;
  1183.     ic_map[fnum][icnum].p_name=iname;
  1184.     ic_map[fnum][icnum].worth.number=ivalue;
  1185.     engrave_int(icnum);
  1186.     icnum++;
  1187.     if (icnum>=VARMAX){
  1188.       clean_local();
  1189.       alert("Maximum number of ints/chars exceeded\n");
  1190.     }
  1191.     ic_map[fnum][icnum].points.x = (WORD) (across + NEXTVAR + ADJUSTX);
  1192.     ic_map[fnum][icnum].points.y = (WORD) down;
  1193.     ic_map[fnum][icnum].points.way = (WORD) FIN_D;
  1194.     ic_map[fnum][icnum].eol.x = (WORD) (across + NEXTVAR + ADJUSTX);
  1195.     ic_map[fnum][icnum].eol.y = (WORD) (down+ADJUSTY);
  1196.     ic_map[fnum][icnum].eol.way = (WORD) TERMINAL;
  1197.   }
  1198. }
  1199.  
  1200. /* engrave_int: Print all aspects of a variable graphic */
  1201.  
  1202. void engrave_int(int idex){
  1203. char keeper[LETWIDTH];
  1204. WORD shuffle_x, shuffle_y;
  1205.  
  1206.     shuffle_x = ic_map[fnum][idex].points.x-ADJUSTX;
  1207.     shuffle_y = ic_map[fnum][icnum].points.y;
  1208.  
  1209.     copy_object(VAR,shuffle_x+2,shuffle_y,&sec_bitmap); /* Print Main Graphic */
  1210.     itochar(ic_map[fnum][idex].worth.number,keeper);
  1211.     writetxt(shuffle_x+4,shuffle_y+39,&sec_rastport,ic_map[fnum][idex].p_name);
  1212.      /* Print Vars Name */
  1213.     writetxt(shuffle_x+4,shuffle_y+54,&sec_rastport,keeper);
  1214.      /* Print Vars value */
  1215.  
  1216. }
  1217.  
  1218.  
  1219. void a_intass(char *dname, char *sname, int ia_hlp){
  1220. VALUE new;
  1221. short ohno=0;
  1222. PLAN arrive;
  1223.  
  1224.   go_code(ia_hlp);
  1225.   if(stop==0){
  1226.       arrive=get_dest(dname);
  1227.       new.number=get_src(sname);
  1228.       comp_scroll();
  1229.       if(stop==0){
  1230.         ohno=putback(back_name,back_x,new);
  1231.         if(ohno==0){
  1232.           clean_local();
  1233.           alert("Failed to assign new value  (a_intass)\n");
  1234.         }
  1235.         arrive.worth.number=new.number;
  1236.         put_road(arrive);
  1237.       }
  1238.   }
  1239. }
  1240.  
  1241. void a_iraypas(char *nrname, int irp_hlp){
  1242. int yoyo=0;
  1243.  
  1244.   go_code(irp_hlp);
  1245.   if(stop==0){
  1246.     if(array_map[raynum][0].p_name==NULL){
  1247.       clean_local();
  1248.       alert("Array has no name (a_iraypas)\n");
  1249.     }
  1250.     raylist[pushn] = array_map[raynum][0].p_name; /* Put name on stack */
  1251.     pushn++;
  1252.     if(pushn>=RECUREDEPTH){
  1253.       clean_local();
  1254.       alert("Name list exceeded limit (a_iraypas)\n");
  1255.     }
  1256.     /* Rename Present Array */
  1257.     while( (array_map[raynum][yoyo].p_name!=NULL) && (yoyo<MEMMAX) ){
  1258.        array_map[raynum][yoyo].p_name=nrname;
  1259.        yoyo++;
  1260.     }
  1261.     /* Draw Renamed Array */
  1262.     yoyo=0;
  1263.     draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1264.     while( (yoyo<MAXACROSS) && (array_map[raynum][yoyo].p_name!=NULL) ){
  1265.       engrave_iray(yoyo,yoyo,0);
  1266.       yoyo++;
  1267.     }
  1268.   }
  1269. }
  1270.  
  1271.  
  1272. /* question takes a string and proceeds to write it on the test display.
  1273.    It first parses the string, gets the first arguments details, types
  1274.    them to the display, then does the same for the second argument,
  1275.    afterwhich it tests them and displays true or false.  Must remember
  1276.    that get_splan returns rec, therefore only one PLAN at a time. */
  1277.  
  1278. void question(char *onlytwo){
  1279. int bee,wasp,click;
  1280. PLAN predone;
  1281. char prname[LETWIDTH];
  1282. SHORT nxt = 0;
  1283. SHORT look = 0;
  1284.  
  1285.       click=0;
  1286.       whatisit(onlytwo);
  1287.       if( (argument[nxt].sign[0]=='-') && (argument[nxt].dexrep==NULL) ){
  1288.          /* Got a negative first argument */
  1289.          nxt++;
  1290.          look=1;
  1291.          predone=get_splan(nxt);
  1292.          bee=predone.worth.number * -1;
  1293.          whatisit(onlytwo); /* Restantiate argument[] get_splan may have altered it */
  1294.       }
  1295.       else{
  1296.          /* Normal first argument */
  1297.          predone=get_splan(nxt);
  1298.          bee=predone.worth.number;
  1299.          look=0;
  1300.          whatisit(onlytwo);
  1301.       }
  1302.       if(predone.p_name==NULL){
  1303.          clean_local();
  1304.          alert("Failed to locate predone coords (question)\n");
  1305.       }
  1306.       get_road(predone);
  1307.       itochar(bee,prname);
  1308.       comp_wrt(click,prname);
  1309.       if(prname[0]!=NULL)
  1310.         click += strlen(prname)+1;
  1311.       else
  1312.         click++;
  1313.       /* Fix for a Test(thing) */
  1314.       if( (argument[nxt].sign[0]!='\0') || (argument[nxt].sign[1]!='\0') ){
  1315.         comp_wrt(click,argument[0].sign);
  1316.         click += strlen(argument[0].sign) + 1;
  1317.         predone=get_splan(nxt);
  1318.         backward_move(pathone,pathone[8],pathone[0],&pulse_sprite);
  1319.         whatisit(onlytwo);
  1320.       }
  1321.       if( (argument[nxt].sign[0]=='\0') && (argument[nxt].sign[1]=='\0') ){
  1322.         /* Assume we are dealing with a test(thing) */
  1323.         /* Argument sign fix */
  1324.         argument[nxt].sign[0]='N';
  1325.         argument[nxt].sign[1]='O';
  1326.         argument[nxt].sign[2]='\0';
  1327.       }
  1328.       else{
  1329.          /* Have a second argument */
  1330.          nxt++;
  1331.          if( (argument[nxt].sign[0]=='-') && (argument[nxt].dexrep==NULL) ){
  1332.            /* Got a negative second argument */
  1333.            nxt++;
  1334.            predone=get_splan(nxt);
  1335.            wasp=predone.worth.number * -1;
  1336.            whatisit(onlytwo);
  1337.          }
  1338.          else{
  1339.            /* Normal */
  1340.            predone=get_splan(nxt);
  1341.            wasp=predone.worth.number;
  1342.            whatisit(onlytwo);
  1343.          }
  1344.          get_road(predone);
  1345.          itochar(wasp,prname);
  1346.          comp_wrt(click,prname);
  1347.       }
  1348.       if(argument[look].sign[1] != '='){
  1349.         switch(argument[look].sign[0]){
  1350.           case '>' :
  1351.             if (bee > wasp)
  1352.               copy_object(ION,32,98,&sec_bitmap);
  1353.             else
  1354.               copy_object(ION,32,147,&sec_bitmap);
  1355.             break;
  1356.           case '<' :
  1357.             if (bee < wasp)
  1358.               copy_object(ION,32,98,&sec_bitmap);
  1359.             else
  1360.               copy_object(ION,32,147,&sec_bitmap);
  1361.             break;
  1362.           case 'N' :
  1363.             if(bee)
  1364.               copy_object(ION,32,98,&sec_bitmap);
  1365.             else
  1366.               copy_object(ION,32,147,&sec_bitmap);
  1367.             break;
  1368.           default :
  1369.             clean_local();
  1370.             alert("Unrecognised sign (question a)\n");
  1371.         }
  1372.       }
  1373.       else{
  1374.         switch(argument[look].sign[0]){
  1375.           case '=' :
  1376.             if (bee == wasp)
  1377.               copy_object(ION,32,98,&sec_bitmap);
  1378.             else
  1379.               copy_object(ION,32,147,&sec_bitmap);
  1380.             break;
  1381.           case '!' :
  1382.             if (bee != wasp)
  1383.               copy_object(ION,32,98,&sec_bitmap);
  1384.             else
  1385.               copy_object(ION,32,147,&sec_bitmap);
  1386.             break;
  1387.           case '>' :
  1388.             if (bee >= wasp)
  1389.               copy_object(ION,32,98,&sec_bitmap);
  1390.             else
  1391.               copy_object(ION,32,147,&sec_bitmap);
  1392.             break;
  1393.           case '<' :
  1394.             if (bee <= wasp)
  1395.               copy_object(ION,32,98,&sec_bitmap);
  1396.             else
  1397.               copy_object(ION,32,147,&sec_bitmap);
  1398.             break;
  1399.           default :
  1400.             clean_local();
  1401.             alert("Unrecognised sign (question b)\n");
  1402.         }
  1403.       }
  1404.       whatisit(onlytwo);
  1405.       chill( STILL/fraction);
  1406.       indicator_clr();
  1407.       backward_move(pathone,pathone[8],pathone[0],&pulse_sprite);
  1408. }
  1409.  
  1410.  
  1411. void a_intcomp(char *f_arg , int ic_hlp)
  1412. {
  1413.  
  1414.   go_code(ic_hlp);
  1415.   if(stop==0){
  1416.       question(f_arg);
  1417.       comp_scroll();
  1418.       al_clean();
  1419.   }
  1420. }
  1421.  
  1422.  
  1423. void a_show(int sh_hlp){
  1424.     go_code(sh_hlp);
  1425.     chill((STILL/5)/fraction);
  1426. }
  1427.  
  1428. /* a_endfunc End a function and restore display of previous function */
  1429.  
  1430. void a_endfunc(char *ename, int e_hlp){
  1431. int abacus=0;
  1432.  
  1433.     /* DOESN'T USE ename */
  1434.     go_code(e_hlp);
  1435.     /* Has the stop button been pressed? */
  1436.     if(stop==0){
  1437.       /* Clear the function parameters */
  1438.       func_index[fnum].f_label = NULL;
  1439.       func_index[fnum].occured[0] = '\0';
  1440.       func_index[fnum].occured[1] = '\0';
  1441.       for(abacus=0;abacus<VARMAX;abacus++){
  1442.         ic_map[fnum][abacus].points.x = (WORD) ICSTARTX;
  1443.         ic_map[fnum][abacus].points.y = (WORD) ICSTARTY;
  1444.         ic_map[fnum][abacus].points.way = (WORD) FIN_D;
  1445.         ic_map[fnum][abacus].p_name=NULL;
  1446.         ic_map[fnum][abacus].eol.x = (WORD) ICSTARTX;
  1447.         ic_map[fnum][abacus].eol.y = (WORD) (ICSTARTY + ADJUSTY);
  1448.         ic_map[fnum][abacus].eol.way = (WORD) TERMINAL;
  1449.       }
  1450.       fnum--;  /* Function down */
  1451.       pushn--; /* Name list down */
  1452.       /* Rename array */
  1453.       if(pushn>=0){
  1454.         abacus=0;
  1455.         while( (array_map[raynum][abacus].p_name!=NULL) && (abacus<MEMMAX) ){
  1456.           array_map[raynum][abacus].p_name=raylist[pushn];
  1457.           abacus++;
  1458.         }
  1459.       }
  1460.       /* Calculate function reference to restore */
  1461.       if(fnum!=-1){
  1462.         clr_dem(); /* Clear the demonstration Display */
  1463.         /* Restore Previous Function Display */
  1464.         draw_modes(0xFF,&sec_rastport,A_BLACK,A_BLACK,JAM1);
  1465.         copy_object(HOLE,8L, 242L, &sec_bitmap);
  1466.         writetxt(341,212,&sec_rastport,func_index[fnum].f_label);
  1467.         writetxt(540,212,&sec_rastport,func_index[fnum].occured);
  1468.         abacus=0;
  1469.         while(ic_map[fnum][abacus].p_name!=NULL){
  1470.           /* Restore Variables */
  1471.           engrave_int(abacus);
  1472.           ++abacus;
  1473.         }
  1474.         abacus=0;
  1475.         if(raynum<0){
  1476.           clean_local();
  1477.           alert("Failed to index array_map (a_endfunc)\n");
  1478.         }
  1479.         while( (array_map[raynum][abacus].p_name!=NULL) && (abacus<MAXACROSS) ){
  1480.           /* Restore Array */
  1481.           engrave_iray(abacus,abacus,0);
  1482.           ++abacus;
  1483.         }
  1484.       }
  1485.     }
  1486. }
  1487.